package com.yzy.fly.config;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yzy.fly.annotation.ParentId;
import com.yzy.fly.asm.annotation.FlyMapper;
import com.yzy.fly.asm.annotation.FlyService;
import com.yzy.fly.kernel.model.FlyBasicModel;
import com.yzy.fly.util.DateUtil;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Collections;
import java.util.Date;
import java.util.List;

@FlyService
@FlyMapper(ds = "fly")
@Data
@TableName(value = "fly_transaction_attribute", autoResultMap = true)
public class FlyTransactionAttribute extends FlyBasicModel<Long, FlyTransactionAttribute> {

    @TableId(type = IdType.AUTO)
    private Long id;

    private String descriptor;

    private String timeoutString;

    private String qualifier;

    private int propagationBehavior;

    private int isolationLevel;

    private int timeout;

    private boolean readOnly = false;

    @TableField(value = "labels", typeHandler = FastjsonTypeHandler.class)
    private List<String> labels = Collections.emptyList();
    @TableField(value = "rollbackForClassNames", typeHandler = FastjsonTypeHandler.class)
    private List<String> rollbackForClassNames = Collections.emptyList();
    @TableField(value = "noRollbackForClassNames", typeHandler = FastjsonTypeHandler.class)
    private List<String> noRollbackForClassNames = Collections.emptyList();

    @DateTimeFormat(pattern = DateUtil.DateFormatPattern.yyyy_MM_dd_HH_mm_ss)
    @JsonFormat(pattern = DateUtil.DateFormatPattern.yyyy_MM_dd_HH_mm_ss)
    @JSONField(format = DateUtil.DateFormatPattern.yyyy_MM_dd_HH_mm_ss)
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    @DateTimeFormat(pattern = DateUtil.DateFormatPattern.yyyy_MM_dd_HH_mm_ss)
    @JsonFormat(pattern = DateUtil.DateFormatPattern.yyyy_MM_dd_HH_mm_ss)
    @JSONField(format = DateUtil.DateFormatPattern.yyyy_MM_dd_HH_mm_ss)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @ParentId(value = "id", parentClass = FlyTransaction.class)
    private Long transactionId;
    private String startupId;
    private String appId;

}